<template>
    <div class="app">
        <!-- title头部 -->
        <div class="title">
            <h3 class="title_h3">
               {{article.title}}
            </h3>
            <p class="title_p">
                 {{article.add_time| fmtdate('YYYY-MM-DD')}} {{article.click}}次浏览 分类：经济民生
            </p>
        </div>
        <!-- content内容 -->
        <div class="content" v-html="article.content">
            
        </div>
        <div>
            <subcomment :artid="artid"></subcomment>
        </div>
    </div>
</template>

<script>
    //导入api的URL
    import common from '../../kits/common.js';
    //导入评论组件 
    import subcomment from '../subcomp/subcomment.vue'

    export default{
        components:{
            subcomment // 2.0 将评论组件注册为私有组件
        },
        created(){
            this.getData();
            this.artid = this.$route.params.id;
           
        },
        data(){
            return{
                article:{},
                artid:0
            }
        },
        methods:{
            getData(){
                //获得传过来的id值
                let id = this.$route.params.id;
                //通过id请求页面的数据
                //  /api/getnew/:newid
                let url = common.apihost+'/api/getnew/'+id;
                //发送数据
                this.$http.get(url).then(res=>{
                    this.article = res.body.message[0];        
                },res=>{
                    console.log('获得图文信息');
                })
            }
        }
    }
</script>
<style scoped>
    .app .title{
        padding-top: 10px;
        border-bottom:1px solid #ddd;
        text-align: left;
    }
    .app .title .title_h3{
        font-size:16px;
        color:#0094ff;
    }
    .app .title .title_p {
        font-size: 12px;
        color:#bbb;
    }
    .app .content{
        text-align: left;
    }
    
</style>